# Copyright (c) 2019 Presto Labs Pte. Ltd.
# Author: jaewon

from experimental.prophet.graph import graph
from experimental.prophet.graph.shape import Shape
from experimental.prophet.graph.util import to_data_type_proto


def placeholder(dtype, shape=None, node_name=None, namespace=None, attrs=None, exec_attrs=None):
  attrs = attrs or {}
  attrs['dtype'] = to_data_type_proto(dtype)
  attrs['shape'] = None if shape is None else Shape(shape).tuple
  node = graph.create_node('Placeholder', [],
                           attrs=attrs,
                           exec_attrs=exec_attrs,
                           name=node_name,
                           namespace=namespace)
  return node.outputs[0]
